package ru.urfc.portal.developer_tasks.ejb_tests;

import javax.ejb.EJB;

import ru.urfc.portal.developer_tasks.BaseTestEjb;
import ru.urfc.portal.developer_tasks.Initializer;
import ru.urfc.portal.managers.AccountingManager;
import ru.urfc.portal.model.Client;
import ru.urfc.portal.model.Branch;
import ru.urfc.portal.model.accounting.Contract;
import ru.urfc.portal.model.accounting.Invoice;

public class AccountingManagerTestEjb extends BaseTestEjb {
	
	@EJB AccountingManager accountingManager;

	Client client;
	Client client2;
	Contract contract;
	Invoice invoice;
	
	@Override
	protected void setUp() throws Exception {
		client = findClient(Initializer.CONTRAGENT_NAME_MTS);
		client2 = findClient(Initializer.CONTRAGENT_NAME_QQ);
		contract = exactlyOne(find(Branch.SVERD, Contract.class, "number", Initializer.CLIENT_MTS_CONTRACT_NUMBER));
		invoice = exactlyOne(find(Branch.SVERD, Invoice.class, "number", Initializer.CLIENT_MTS_INVOICE_NUMBER));
	}
	
	public void testGetContractException() {
		accountingManager.getContract(client.getId(), contract.getId());
		setExpectedUserGetItemException();
		accountingManager.getContract(client2.getId(), contract.getId());
	}
	
	public void testGetInvoice() {
		accountingManager.getInvoice(client.getId(), invoice.getId());
		setExpectedUserGetItemException();
		accountingManager.getInvoice(client2.getId(), invoice.getId());
	}
	

}
